<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 说明：ES6新增，class是一个语法糖，就是基于寄生组合继承来实现的；
        class Parent5 {
            constructor() {
                this.name = 'Parent5'
                this.arr = [1, 2, 3]
            }
            say() {
                console.log(this.name)
            }
        }
        class Child5 extends Parent5 {
            constructor() {
                super() //通过super()调用父类构造函数 相当于Parent5.prototype.constructor.call(this)  
                this.type = "Child5"
            }
        }
        let child5_1 = new Child5()
        let child5_2 = new Child5()
        child5_1.arr.push(4)
        console.log(child5_1.say()) // Parent5
        console.log(child5_1.arr, child5_2.arr) // [1, 2, 3, 4]  [1, 2, 3]
        console.log(child5_1.constructor === Child5) // true 
        console.log(child5_2.constructor === Parent5) // false

    </script>
</body>

</html>